﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceable.App.Application.Command.Slaughter;
using Traceable.App.DTOS;
using Traceable.ErrorCode;

namespace Traceable.App.Controllers
{
    /// <summary>
    /// 屠宰服务
    /// </summary>
    [Route("api/[controller][action]")]
    [ApiController]
    public class SlaughterController : ControllerBase
    {
        IMediator _mediator;

        public SlaughterController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 获取屠宰基本信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public Task<ApiResult<SlaughterDto>> GetSlaugther([FromQuery]GetSlaughterListCommand request)
        {
            return _mediator.Send(request);
        }
        /// <summary>
        /// 设置屠宰信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public Task<ApiResult<int>> SeaveSlaugther(SeaveSlaugtherCommand request)
        {
            return _mediator.Send(request); 
        }
    }
}
